import { createSlice } from '@reduxjs/toolkit';

// 使用该类型定义初始 state
const initialState = {
  id: 110100,
  name: '北京',
  list: [],
};

const slice = createSlice({
  name: 'city',
  initialState,
  reducers: {
    changeCity(state, action) {
      let { id, name } = action.payload;
      state.id = id;
      state.name = name;
    },
    changeCityList(state, action) {
      state.list = action.payload;
    },
    fetchCityList(state, action) {},
  },
});

export const { changeCity, changeCityList } = slice.actions;
export default slice.reducer;
